<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<style>
			html,
			body {
				width: 100%;
				height: 100%;
			}
			
			.mui-preview-image.mui-fullscreen {
				position: fixed;
				z-index: 20;
				background-color: #000;
			}
			
			.mui-preview-header,
			.mui-preview-footer {
				position: absolute;
				width: 100%;
				left: 0;
				z-index: 10;
			}
			
			.mui-preview-header {
				height: 44px;
				top: 0;
			}
			
			.mui-preview-footer {
				height: 50px;
				bottom: 0px;
			}
			
			.mui-preview-header .mui-preview-indicator {
				display: block;
				line-height: 25px;
				color: #fff;
				text-align: center;
				margin: 15px auto 4;
				width: 70px;
				background-color: rgba(0, 0, 0, 0.4);
				border-radius: 12px;
				font-size: 16px;
			}
			
			.mui-preview-image {
				display: none;
				-webkit-animation-duration: 0.5s;
				animation-duration: 0.5s;
				-webkit-animation-fill-mode: both;
				animation-fill-mode: both;
			}
			
			.mui-preview-image.mui-preview-in {
				-webkit-animation-name: fadeIn;
				animation-name: fadeIn;
			}
			
			.mui-preview-image.mui-preview-out {
				background: none;
				-webkit-animation-name: fadeOut;
				animation-name: fadeOut;
			}
			
			.mui-preview-image.mui-preview-out .mui-preview-header,
			.mui-preview-image.mui-preview-out .mui-preview-footer {
				display: none;
			}
			
			.mui-zoom-scroller {
				position: absolute;
				display: -webkit-box;
				display: -webkit-flex;
				display: flex;
				-webkit-box-align: center;
				-webkit-align-items: center;
				align-items: center;
				-webkit-box-pack: center;
				-webkit-justify-content: center;
				justify-content: center;
				left: 0;
				right: 0;
				bottom: 0;
				top: 0;
				width: 100%;
				height: 100%;
				margin: 0;
				-webkit-backface-visibility: hidden;
			}
			
			.mui-zoom {
				-webkit-transform-style: preserve-3d;
				transform-style: preserve-3d;
			}
			
			.mui-slider .mui-slider-group .mui-slider-item img {
				width: auto;
				height: auto;
				max-width: 100%;
				max-height: 100%;
			}
			
			.mui-android-4-1 .mui-slider .mui-slider-group .mui-slider-item img {
				width: 100%;
			}
			
			.mui-android-4-1 .mui-slider.mui-preview-image .mui-slider-group .mui-slider-item {
				display: inline-table;
			}
			
			.mui-android-4-1 .mui-slider.mui-preview-image .mui-zoom-scroller img {
				display: table-cell;
				vertical-align: middle;
			}
			
			.mui-preview-loading {
				position: absolute;
				width: 100%;
				height: 100%;
				top: 0;
				left: 0;
				display: none;
			}
			
			.mui-preview-loading.mui-active {
				display: block;
			}
			
			.mui-preview-loading .mui-spinner-white {
				position: absolute;
				top: 50%;
				left: 50%;
				margin-left: -25px;
				margin-top: -25px;
				height: 50px;
				width: 50px;
			}
			
			.mui-preview-image img.mui-transitioning {
				-webkit-transition: -webkit-transform 0.5s ease, opacity 0.5s ease;
				transition: transform 0.5s ease, opacity 0.5s ease;
			}
			
			@-webkit-keyframes fadeIn {
				0% {
					opacity: 0;
				}
				100% {
					opacity: 1;
				}
			}
			
			@keyframes fadeIn {
				0% {
					opacity: 0;
				}
				100% {
					opacity: 1;
				}
			}
			
			@-webkit-keyframes fadeOut {
				0% {
					opacity: 1;
				}
				100% {
					opacity: 0;
				}
			}
			
			@keyframes fadeOut {
				0% {
					opacity: 1;
				}
				100% {
					opacity: 0;
				}
			}
			
			p img {
				max-width: 100%;
				height: auto;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">公司详情</h1>
		</header>
		<div class="mui-content" style="top: 9%;position:relative;padding: 0px;width: 100%;background-color: #FFFFFF;padding-top: 1em;">
			<div style="width: 100%;padding-left: 1em;">
				<p id="title_company_name" style="font-size: 100%;margin: 0px;display: inline;color: #000000;"></p>
				<p id="title_company_type" style="font-size: 70%;margin: 0px;display: inline;text-indent: 1em;color: #CF2D28;"></p>
			</div>

			<div style="width: 100%;height: 1em;padding-left: 1.2em;margin-top: 0.2em;">
				<div id="add_tags" style="display: inline;">

				</div>
				<div id="star_add" class="mui-pull-right" style="display: inline;padding-right:10% ;">
					<!--<span class="mui-icon mui-icon-star-filled" style="font-size: 1em;color: #DD524D;"></span>
					<span class="mui-icon mui-icon-star-filled" style="font-size: 1em;color: #DD524D;"></span>
					<span class="mui-icon mui-icon-star-filled" style="font-size: 1em;color: #DD524D;"></span>
					<span class="mui-icon mui-icon-star-filled" style="font-size: 1em;color: #DD524D;"></span>
					<span class="mui-icon mui-icon-star-filled" style="font-size: 1em;color: #DD524D;"></span>-->
				</div>
			</div>
			<div id="add_images" class="mui-content" style="background-color:#FFFFFF;height:20%;white-space: nowrap;margin: 3% 0px;padding: 0px;margin-bottom: 0px;">

			</div>
			<div>
				<ul class="mui-table-view">
					<li id="li_navigation" class="mui-table-view-cell">
						<a class="mui-navigate-right" style="font-size: 1em;padding: 0px;height: 2.5em;line-height: 1.25em;position: relative;padding-left: 1em;">
							<img class="mui-icon mui-pull-left" src="../image/coordinate.png" style="padding: 5px 0px;width: 1em;" />
							<p class="mui-ellipsis" id="address_title" style="padding: 10px 0px;color: #000000;"></p>
						</a>
					</li>
					<li id="li_call" class="mui-table-view-cell">
						<a class="mui-navigate-right" style="font-size: 1em;padding: 0px;height: 2.5em;line-height: 1.25em;position: relative;padding-left: 1em;">
							<img class="mui-icon mui-pull-left" src="../image/coordinate.png" style="padding: 5px 0px;width: 1em;" />
							<p id="phone_title" style="padding: 10px 0px;color: #000000;"></p>
						</a>
					</li>
					<!--<li class="mui-table-view-cell">
						<a class="mui-navigate-right" style="font-size: 1em;padding: 0px;height: 2.5em;line-height: 1.25em;position: relative;padding-left: 1em;">
							<img class="mui-icon mui-pull-left" src="../image/coordinate.png" style="padding: 5px 0px;width: 1em;" />
							<p style="padding: 10px 0px;color: #000000;">这里关注二维码</p>
						</a>
					</li>-->
				</ul>
			</div>
			<ul style="width: 100%;padding: 0px;margin: 0px;background-color: #FFFFFF;border-bottom: solid 1px;border-color:#CCCCCC;">
				<li style="display: inline-block;width: 32%;text-align: center;border-right: solid 1px;border-color: #BBBBBB;">
					<p id="com_level_title" style="display: inline-block;font-size: 60%;margin: 0px;"></p>
				</li>
				<li style="display: inline-block;width: 32%;text-align: center;border-right: solid 1px;border-color: #BBBBBB;">
					<p id="com_area_title" style="display: inline-block;font-size: 60%;margin: 0px;">孵化面积：1000平米</p>
				</li>
				<li style="display: inline-block;width: 32%;text-align: center;">
					<p id="com_num_title" style="display: inline-block;font-size: 60%;margin: 0px;">企业数量：20个</p>
				</li>
			</ul>
			<p id="com_service" class="mui-text-left" style="padding: 1%;color: #000000;"></p>
			<p id="com_descr" class="mui-text-left" style="padding: 1%;margin-top:1%;color: #000000;"></p>
			<ul class="mui-table-view">
				<li class="mui-table-view-cell" id="a_comment">
					<a class="mui-navigate-right" style="font-size: 70%;" href="../examples/comment.html">
						<span class="mui-icon mui-icon-chat" style="font-size: 120%;color: #DD524D;"></span>&nbsp;&nbsp;&nbsp;&nbsp;点评
					</a>
				</li>
			</ul>

			<div id="commonts">
				<div style="min-height: 1em;background: #fff;" id="div">
					<!--<div style="margin:0.7em;border-bottom: 1px solid darkgrey ;padding-bottom: 0.7em;">
						<p style="color: #000;font-size: 0.9em" id='p_comment'>这是第一条评价</p>
						<p style="font-size: 0.8em;color: darkgrey;padding-bottom: 0.5em;"><span style="float: right;">2017-2-15</span></p>
					</div>-->
				</div>
			</div>

		</div>
		<script src="../js/jquery-3.1.1.min.js"></script>
		<script src="../js/mui.min.js"></script>
		<script src="../js/initData.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/mui.zoom.js"></script>
		</s>
		<script src="../js/mui.previewimage.js"></script>
		<script type="text/javascript">
			mui.init();
			mui.plusReady(function() {
				document.getElementById("a_comment").addEventListener("tap", function() {
					mui.openWindow({
						url: 'comment.html',
						id: 'comment.html',
						extras: {
							company_id: com_id
						}
					});
				});
			});

			function addStar(num) {

				var _star = '<span class="mui-icon mui-icon-star-filled" style="font-size: 1em;color: #DD524D;"></span>';
				var _unstar = '<span class="mui-icon mui-icon-star" style="font-size: 1em;color: #DD524D;"></span>';
				var value = "";
				for(var i = 0; i < 5; i++) {
					if(i < num) {
						value = value + _star;
					} else {
						value = value + _unstar;
					}
				}
				return value;
			}

			function addTags(tags) {
				var value = "";
				/*if(tags != null) {
					for(var i = 0; i < tags.split(",").length; i++) {
						var tag = '<p style="border:1px solid;width:4em;text-align: center;display: inline;font-size: 0.5em;color: #EC971F;">' + tagsToChinese(tags.split(",")[i]) + '</p>&nbsp;';
						value = value + tag;
					}
				} else {
					value = '<p style="border:1px solid;width:4em;text-align: center;display: inline;font-size: 0.5em;color: #EC971F;">暂无</p>&nbsp;';
				}*/
				return value;
			}

			function addImages(imgs) {
				console.log(imgs)
				var value = "";
				if(imgs != "") {
					if(imgs != "undefined") {
						console.log("imgs=" + imgs);
						if(imgs.indexOf(",") == 0) {
							imgs = imgs.substring(1);
						}
						var num = imgs.split(",").length;
						if(num > 4) {
							num = 4;
						}
						for(var i = 0; i < num; i++) {
							var urlimages = "http://upday.ecst.com.cn:81/" + imgs.split(",")[i];
							console.log(urlimages)
							var img = '<img src="' + urlimages + '" data-preview-src="" data-preview-group="1" style="width: 25%;padding: 0px;display: inline;padding: 0px;border: none;margin: 0px;" />';
							value = value + img
							console.log(value)
						}
					}

				} else {
					console.log("else=" + value);
					value = '<img src="" data-preview-src="" data-preview-group="1" style="width: 25%;padding: 0px;display: inline;padding: 0px;border: none;margin: 0px;" />';
				}

				console.log(value)
				return value;
			}

			function showPage() {
				
				document.getElementById("title_company_name").innerText = com_name;
				document.getElementById("title_company_type").innerText = com_type;
				document.getElementById("address_title").innerText = com_address;
				document.getElementById("phone_title").innerText = com_phone;
				document.getElementById("com_level_title").innerText = "级别：" + com_level;
				document.getElementById("com_num_title").innerText = "企业数量：" + com_num + "个";
				document.getElementById("com_area_title").innerText = "孵化面积：" + com_area + "平米";
				document.getElementById("com_descr").innerText = "简介：" + com_descr;
				document.getElementById("star_add").innerHTML = addStar(com_score);
				document.getElementById("com_service").innerText = "服务内容：" + com_service;
				document.getElementById("add_tags").innerHTML = addTags(com_tags);
				document.getElementById("add_images").innerHTML = addImages(com_images);
				plus.webview.currentWebview().show();
				plus.nativeUI.closeWaiting();
			}
			mui.previewImage();
			mui.init();
			var com_text = "";
			var com_time = "";
			var com_id = "";
			var com_name = "";
			var com_type = "";
			var com_address = "";
			var com_phone = "";
			var com_num = "0";
			var com_area = "0";
			var com_location_jingdu = "";
			var com_location_weidu = "";
			var com_descr = "暂无简介。";
			var com_score = 0;
			var com_level = "";
			var com_images = [];
			var com_service = "暂无。";
			var com_tags = [];
			var com_images = [];
			mui.plusReady(function() {
				com_id = plus.webview.currentWebview().company_id;
				console.log("公司名:" + com_name + ",公司类型:" + com_type + ",公司地址:" + com_address + ",公司电话:" + com_phone + "，公司数量：" + com_num + "个,公司面积：" + com_area + ",公司经纬度：" + com_location_jingdu + "," + com_location_weidu);
				mui('.mui-scroll-wrapper').scroll({
					indicators: true, //是否显示滚动条
					bounce: false
				});
				console.log("url=" + url_getcompany_info + "id=" + com_id)
				mui.ajax(url_getcompany_info, {
					data: {
						"id": com_id,
					},
					type: 'get', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					success: function(data) {
						plus.nativeUI.closeWaiting();
						console.log(data)
						var value = JSON.parse(data).value
						body = JSON.parse(data).value;
						if(body != null) {
							if(body.images != null) {
								com_images = body.images
							}
							com_name = body.name;
							switch(body.type) {
								case "incubator":
									com_type = "(孵化器)";
									break;
								case "gis":
									com_type = "(众创空间)";
									break;
								case "tech_park":
									com_type = "(科技园)";
									break;
							}
							switch(body.address) {
								case null:
									com_address = "暂无";
									break;
								default:
									com_address = body.address;
									break;
							}
							switch(body.phone) {
								case null || "undefined":
									com_phone = "暂无";
									break;
								default:
									com_phone = body.phone;
									break;
							}
							com_num = body.companyNum;

							com_tags = body.tags;

							if(body.area != null) {
								com_area = body.area;
							}
							com_location_jingdu = body.lng;
							com_location_weidu = body.lat;
							switch(body.level) {
								case "country":
									com_level = "国家级";
									break;
								case "city":
									com_level = "市级";
									break;
								default:
									com_level = "待添加";
									break;
							}
							com_descr = body.description;
							com_service = body.service;
							document.getElementById("li_call").addEventListener("tap", function() {
								plus.device.dial(com_phone, true);
							});
							document.getElementById("li_navigation").addEventListener("tap", function() {
								plus.geolocation.getCurrentPosition(function(position) {
									var locations = position.coords.longitude + "," + position.coords.latitude;
									var dst = new plus.maps.Point(com_location_jingdu, com_location_weidu);
									var src = new plus.maps.Point(position.coords.longitude, position.coords.latitude);
									plus.maps.openSysMap(dst, com_name, src);
								});
							});
							com_score = body.score;
						}

						showPage();
					},
					error: function(xhr, type, errorThrown) { //异常处理；
						showPage()
						console.log(type);
						console.log(errorThrown);
						plus.nativeUI.closeWaiting();
					}
				});

				mui.ajax(url_supporter_comments, {
					data: {
						"id": com_id,
						"pn": 1
					},
					type: 'get', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					success: function(data) {
						plus.nativeUI.closeWaiting();
						var array = JSON.parse(data).value;
						mui.each(array, function(index, item){
							var test = new Date(parseInt(item.createDate) );  
						    var $_year = test.getFullYear();  
						    var $_month = parseInt(test.getMonth())+1;  
						    var $_day = test.getDate();  
						    var $_f_date =  $_year +"-"+$_month+"-"+$_day  
							item = "<div style='margin:0.7em;border-bottom: 1px solid darkgrey ;padding-bottom: 0.7em;'><p style='color: #000;font-size: 0.9em'>"+item.text+"</p><p style='font-size: 0.8em;color: darkgrey;padding-bottom: 0.5em;'><span style='float: right;'>"+$_f_date+"</span></p></div>";
								
                        	$('#div').append(item);
						});
					},
					error: function(xhr, type, errorThrown) { //异常处理；
						console.log(type);
						console.log(errorThrown);
						plus.nativeUI.closeWaiting();
					}
				});

			})
		</script>
	</body>

</html>